﻿using FinPlusComponents;
using QLNet;
using p = FinPlusAnalytics.QLConvParser;

namespace FinPlusAnalytics
{
    public class DepoRate : FinPlusComponent
    {
        public string Name { get; private set; }
        public RelinkableHandle<Quote> Rate { get; private set; }
        public RateHelper RateHelper { get; private set; }

        public DepoRate(string marketName, string name, double rate, string tenor, int fixingDays, string dayCount, string bizConv, string holidays, bool endOfMonth = true)
        {
            Name = name;
            var market = Markets.Instance.GetMarket(marketName);

            Rate = market.GetQuote(name);
            Rate.linkTo(new SimpleQuote(rate));
            
            RateHelper = new DepositRateHelper(Rate, p.GetPeriod(tenor), fixingDays, p.Calendar(holidays), p.BizConv(bizConv), endOfMonth,  p.DayCount(dayCount));
            market.SetRateHelper(name, RateHelper);

        }
    }
}
